<%@ page isELIgnored="false" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录页面</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f0f0f0;
        }
        h1 {
            color: #333;
            text-align: center;
        }
        form {
            width: 300px;
            margin: 0 auto;
            background-color: #fff;
            padding: 20px;
            border-radius: 5px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
        }
        label {
            display: block;
            margin-bottom: 5px;
        }
        span {
            color: red;
        }
        input[type="text"], input[type="password"] {
            width: 100%;
            padding: 5px;
            margin-bottom: 20px;
            border: 1px solid #ccc;
            border-radius: 3px;
        }
        input[type="submit"] {
            width: 100%;
            padding: 10px;
            background-color: #007BFF;
            color: #fff;
            border: none;
            border-radius: 3px;
            cursor: pointer;
        }
        input[type="submit"]:hover {
            background-color: #0056b3;
        }
        form {
            text-align: center;
        }
    </style>
</head>
<body>
<h1>学生管理系统</h1>
<form action="${pageContext.request.contextPath}/login?method=login" method="post" onsubmit="return validateForm()">
    <label for="username">用户名：</label>
    <input type="text" id="username" name="username" required><br><br>
    <label for="password">密码：</label>
    <input type="password" id="password" name="password" required><br><br>
    <span>${errl}</span>
    <input type="submit" value="登录">
</form>
<script>
    function validateForm() {
        var username = document.getElementById("username").value;
        var password = document.getElementById("password").value;
        var error = document.getElementById("error");

        if (username.length < 6 || username.length > 18 || password.length < 6 || password.length > 18) {
            alert("用户名和密码长度必须在6-18位之间");
            return false;
        } else {
            error.innerHTML = "";
            return true;
        }
    }
</script>
</body>
</html>

